<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    function func() {
        var d1 = +new Date();
        var arr = [];
        for (let i = 0; i < 1000; i++) {
            arr.push('<div style="width: 100px; height: 2px; border: 1px solid red"> </div>');
            // document.body.innerHTML += '<div style="width: 100px; height: 2px; border: 1px solid red"> </div>'
        }
        document.body.innerHTML = arr.join('')

        var d2 = +new Date();       // 使用数组形式拼接, 效率最高 2ms
        console.log(d2 - d1);       // 原生字符串拼接的方式 1131ms
    }

    func()
</script>
</body>


</html>
